package sddz.foodmanage.utils;

import android.view.View;

import com.blankj.utilcode.util.SnackbarUtils;

import static com.blankj.utilcode.util.SnackbarUtils.LENGTH_INDEFINITE;

/**
 * Created by Administrator on 2017/9/23.
 */

public class SnackbarHelper {

    public static void show(View view, String message) {
        show(view, message, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SnackbarUtils.dismiss();
            }
        });
    }

    public static void show(final View view, String message, final View.OnClickListener onClickListener) {
        show(view,message,"确认",onClickListener);
    }

    public static void show(final View view, String message, String actionName, final View.OnClickListener onClickListener) {
        SnackbarUtils.with(view).setMessage(message).setAction(actionName, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SnackbarUtils.dismiss();
                if (onClickListener != null) {
                    onClickListener.onClick(view);
                }
            }
        }).setDuration(LENGTH_INDEFINITE).show();
    }

    public static void showSystem(View view) {
        SnackbarUtils.with(view).setMessage("网络或服务器异常，请检查网络后重试").setAction("确认", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SnackbarUtils.dismiss();
            }
        }).setDuration(LENGTH_INDEFINITE).show();
    }

}
